package DataStreamApi.Source读取;


import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;
import java.util.List;

/**
 *从集合中读取数据
 */
public class Flink01_Collect {
    public static void main(String[] args) throws Exception {

        /**
         * 创建执行环境
         * IDEA运行的时候，
         * 需要导入依赖
         */
        StreamExecutionEnvironment executionEnvironment = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(new Configuration());

        List<Integer> data = Arrays.asList(1, 2, 3, 4, 5);

        DataStreamSource<Integer> integerDataStreamSource1 = executionEnvironment.fromCollection(data);



        /**
         * 直接遍历元素
         */
        DataStreamSource<Integer> integerDataStreamSource3 = executionEnvironment.fromElements(1,2,3,4,5,6,7);


        integerDataStreamSource1.print();
        System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
        integerDataStreamSource3.print();

        executionEnvironment.execute();


    }
}
